package com.company.lanqiao;

import java.util.Scanner;

public class ExchangeTheBottle {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n + 1];

        for (int i = 1; i < nums.length; i++) {
            nums[i] = sc.nextInt();
        }

        int res = 0;
        // 3 1 2 5 4
        for (int i = 1; i < nums.length; i++) {
            while (i != nums[i]) {
                int temp = nums[nums[i]];
                nums[nums[i]] = nums[i];
                nums[i] = temp;
                res++;
            }
        }
        System.out.println(res);
    }

}
